﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VelocityShop.Entities;

namespace VelocityShop.Web.UI
{
    public partial class ShoppingCart : System.Web.UI.UserControl
    {
        private Cart _cart;
        private Catalog _catalog = new Catalog("", "EUR");

        public Catalog Catalog
        {
            get { return _catalog; }
        }

        public Cart Cart
        {
            get
            {

                if (_cart == null)
                {
                    if (Session["ShoppingCart"] == null)
                    {
                        _cart = new Cart();
                        Session["ShoppingCart"] = _cart;
                    }
                    else
                    {
                        _cart = (Cart)Session["ShoppingCart"];
                    }
                }

                return _cart;
            }
        }

        public void UpdateCart()
        {
            repCart.DataSource = Cart.Items;
            repCart.DataBind();
            emptyMsg.Visible =(Cart.Items.Count==0);

        }

    }
}